﻿// Copyright (c) 2014 Converter Systems LLC

using ConverterSystems.Windows.Data;
using MahApps.Metro;
using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;

namespace ConverterSystems.Workstation.Data
{
    [ValueConversion(typeof(AppTheme), typeof(Brush))]
    public class ThemeToBrushConverter : ValueConverter<AppTheme, Brush>
    {
        protected override Brush Convert(AppTheme value, object parameter, CultureInfo culture)
        {
            if (value == null) throw new ArgumentNullException("value");
            var b = value.Resources["WindowBackgroundBrush"] as Brush;
            if (b != null)
            {
                return b;
            }
            return Brushes.White;
        }
    }
}